package com.zsq.thread.test1;

import java.util.concurrent.Executors;

/**
 * @author : zhang sq
 * @date : 2019/12/25 20:39
 **/
//线程启动方式
public class StartThread {

    public static void main(String[] args) throws Exception {
        //1.继承
        new MyThread().start();
        //2.实现
        new Thread(new MyRun()).start();
        //3.lambda表达式
        new Thread(() -> {
            System.out.println("java8");
        }).start();
        //4.executors 调用callable .call方法
        Executors.callable(new MyRun()).call();

    }

    //继承
    static class MyThread extends Thread {
        @Override
        public void run() {
            System.out.println("Hello MyThread");
        }
    }

    //实现
    static class MyRun implements Runnable {
        @Override
        public void run() {
            System.out.println("Hello MyRun");
        }
    }
}
